package demo4;

/**
 * Author：毕龙
 * Date: 2024/5/17 10:49
 */
public class Testquestion5 {
    public static void main(String[] args) {
        String str = "aaabbbbbcccccdddddihhhccc";
        StringBuilder sb = new StringBuilder();
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            //该字符不存在则添加到sb中
            if (!sb.toString().contains(c + "")){
                sb.append(c+"");
                count++;
                //从开始添加的位置到整个字符串结束看有多少个该字符
                for (int j = i+1; j < str.length(); j++) {
                    //获取后面相同的字符
                    char c1 = str.charAt(j);
                    //判断后面获取的字符跟前面要放的字符相同
                    if ( c == c1 ){
                        //统计个数
                        count++;
                    }
                }
                if(count!=1){
                    sb.append(count);
                }
                count=0;
            }

        }
        System.out.println(sb);
    }
}
